<?php
/**
 * GioCMS
 * 
 * LICENSE
 *
 * This source file is subject to the GNU GENERAL PUBLIC LICENSE Version 2 
 * that is bundled with this package in the file LICENSE.txt.
 * It is also available through the world-wide-web at this URL:
 * http://www.gnu.org/licenses/gpl-2.0.txt
 * If you did not receive a copy of the license and are unable to
 * obtain it through the world-wide-web, please send an email
 * to license@ninhgio.com so we can send you a copy immediately.
 * 
 * @copyright	Copyright (c) 2010-2011 GioCMS (http://cms.ninhgio.com)
 * @license		http://www.gnu.org/licenses/gpl-2.0.txt GNU GENERAL PUBLIC LICENSE Version 2
 * @author		NinhGio - ninhgio@gmail.com
 * @since		1.0
 * @version		$Id:$
 */

/**
 * Check PHP version
 */
if (version_compare(phpversion(), '5.0.0', '<') === true) {
    die('ERROR: Your PHP version is ' . phpversion() . '. GioCMS requires PHP 5.0.0 or newer.');
}

@session_start();
ini_set("display_errors", 1);
error_reporting(E_ALL);
date_default_timezone_set('Asia/Saigon');

define('DS', DIRECTORY_SEPARATOR);
define('PS', PATH_SEPARATOR);
define('ROOT_DIR', dirname(__FILE__));
define('CONFIG_DIR', ROOT_DIR . DS . 'configs');
define('TEMP_DIR', ROOT_DIR . DS . 'temp');
define('TEMPLATE_DIR', ROOT_DIR . DS . 'templates');
define('LIB_DIR', ROOT_DIR . DS . 'libraries');
define('MOD_DIR', ROOT_DIR . DS . 'modules');

set_include_path(PS . LIB_DIR . DS . 'htmlpurifier'
					. PS . get_include_path());

require LIB_DIR . DS . 'gio' . DS . 'core' . DS . 'AutoLoader.php';
require LIB_DIR . DS . 'PEAR' . DS . 'Services' . DS . 'JSON.php';

/**
 * Set Exception Handler
 */
set_exception_handler(array('Gio_Core_Exception', 'exception'));

/**
 * Register plugin
 */
Gio_Core_Application::getInstance()
		->registerPlugin('Modules_Core_Controllers_Plugins_OfflineMessage')
		//->registerPlugin('Modules_Cms_Controllers_Plugins_Auth')
		->registerPlugin('Modules_Core_Controllers_Plugins_AdminAuth')
		->registerPlugin('Modules_Core_Controllers_Plugins_RuleChecker')
		->registerPlugin('Modules_Core_Controllers_Plugins_HookLoader')
		/**
		 * Run application
		 */
		->run();
		
		